import { applyMiddleware, createStore, combineReducers} from 'redux'
import { composeWithDevTools } from 'remote-redux-devtools';
import thunk from 'redux-thunk'
import reducers from '../reducers'

const logger = store => next => action => {
  console.log('dispatching', action)
  next(action)
  console.log('next state', store.getState())
}

const middlewares = [
  logger,
  thunk
]

// 组合增强
const composeEnhancers = composeWithDevTools({
  // Specify here name, actionsBlacklist, actionsCreators and other options
});

const reducer = combineReducers(reducers)

export const store = createStore(
  reducer,
  undefined,
  composeEnhancers(
    applyMiddleware(...middlewares)
  )
)

